package com.feng.gameproj;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.FontMetrics;
import android.view.View;

public class TextFontView extends View implements Runnable 
{
	private String text = null;
	private Paint paint = null;
	private FontMetrics font = null;

	public TextFontView(Context context) 
	{
		super(context);
		
		this.text = "line 1 ";
		this.paint = new Paint ();
		this.font = this.paint.getFontMetrics();
		
		new Thread (this).start ();
	}

	@Override
	protected void onDraw(Canvas canvas) 
	{
		super.onDraw(canvas);
		
		this.paint.setTextSize(12);
		this.paint.setARGB(255, 25, 250, 30);
		this.paint.setFlags(Paint.ANTI_ALIAS_FLAG);
		
		// 设置Font Metrics -- 效果未知
		this.font.bottom = 5;
		
		canvas.drawText(this.text, 10, 10, this.paint);
	}

	@Override
	public void run() 
	{
		while (! Thread.currentThread().isInterrupted())
		{
			try 
			{
				Thread.sleep(500);
				text += "Kelly";
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				Thread.currentThread().interrupt();
			}
			postInvalidate ();
		}
	}

}
